# coding=utf-8
import time

from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException, TimeoutException

# 实例化，以Chrome打开
driver = webdriver.Chrome()
try:
    driver.get("https://www.baidu.com")
except TimeoutException as e:
    pass
try:
    driver.find_element_by_id("su")
except NoSuchElementException as e:
    pass

driver.execute_script("window.open()")
print(driver.window_handles)

driver.switch_to_window(driver.window_handles[1])
driver.get("https://www.taobao.com")
time.sleep(1)
driver.switch_to_window(driver.window_handles[0])
driver.get("https://python.org")

